-
Notifications
You must be signed in to change notification settings - Fork 1
Feature/flask smorest category #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… views, blueprints, and marshmallow schemas
…andle IntegrityError in test_create_category_duplicate_name
WalkthroughPluralizes category API paths from /category to /categories, migrates category endpoints to a new Flask-Smorest blueprint with Marshmallow schemas, wires Api(app) and OpenAPI config, removes legacy category routes, adds new dependencies, and updates tests and README accordingly. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Client
participant App as Flask App
participant API as Smorest Api
participant BP as Category Blueprint
participant JWT as JWT Ext
participant DB as SQLAlchemy/DB
rect rgb(240,248,255)
note over Client,DB: List categories (GET /categories)
Client->>App: GET /categories
App->>API: dispatch request
API->>BP: CategoryCollection.get
BP->>DB: Category.query.all()
DB-->>BP: categories
BP-->>Client: 200 JSON
end
rect rgb(245,255,240)
note over Client,DB: Create category (POST /categories) [protected]
Client->>App: POST /categories (JSON)
App->>API: dispatch
API->>JWT: verify access token
JWT-->>API: ok / error
alt token valid
API->>BP: CategoryCollection.post
BP->>DB: validate subcategory IDs
DB-->>BP: ok / missing
alt valid
BP->>DB: insert Category, commit
DB-->>BP: created
BP-->>Client: 201 JSON
else invalid
BP-->>Client: 422 error
end
else invalid token
API-->>Client: 401 error
end
end
rect rgb(255,250,240)
note over Client,DB: Paginated products (GET /categories/{id}/products?page=n)
Client->>App: GET /categories/123/products?page=2
App->>API: dispatch
API->>BP: CategoryProducts.get
BP->>DB: exists(Category.id==123)?
alt exists
BP->>DB: query products, paginate (10/page)
DB-->>BP: items + meta
BP-->>Client: 200 JSON
else not found
BP-->>Client: 404
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Ruff (0.13.1)app/__init__.py�[1;31mruff failed�[0m app/migrated_routes/category.py�[1;31mruff failed�[0m tests/test_category.py�[1;31mruff failed�[0m
Tip 👮 Agentic pre-merge checks are now available in preview!Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.
Please see the documentation for more information. Example: reviews:
pre_merge_checks:
custom_checks:
- name: "Undocumented Breaking Changes"
mode: "warning"
instructions: |
Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).Please share your feedback with us on this Discord post. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (9)
README.md(2 hunks)app/__init__.py(2 hunks)app/migrated_routes/category.py(1 hunks)app/routes.py(1 hunks)app/schemas.py(1 hunks)requirements.txt(1 hunks)tests/conftest.py(1 hunks)tests/test_category.py(7 hunks)tests/test_relationships.py(5 hunks)
🧰 Additional context used
🧬 Code graph analysis (6)
app/routes.py (1)
app/models.py (3)
Category(77-93)Subcategory(96-113)Product(116-134)
app/schemas.py (1)
app/models.py (3)
Category(77-93)Product(116-134)Subcategory(96-113)
app/migrated_routes/category.py (2)
app/models.py (3)
Category(77-93)Product(116-134)Subcategory(96-113)app/schemas.py (6)
CategoriesOut(12-13)CategoryIn(16-33)CategoryOut(7-9)PaginationArgs(54-55)ProductsOut(50-51)SubcategoriesOut(41-42)
tests/test_category.py (2)
tests/conftest.py (3)
create_category(54-63)create_authenticated_headers(43-50)client(14-21)app/migrated_routes/category.py (2)
put(129-180)delete(184-209)
tests/conftest.py (1)
app/migrated_routes/category.py (1)
post(47-94)
tests/test_relationships.py (2)
tests/conftest.py (3)
client(14-21)create_category(54-63)create_subcategory(67-78)app/migrated_routes/category.py (1)
put(129-180)
🪛 markdownlint-cli2 (0.18.1)
README.md
108-108: Fenced code blocks should be surrounded by blank lines
(MD031, blanks-around-fences)
108-108: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: deploy-preview
Summary by CodeRabbit